home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / utilities / emulators / apple2emul.lzh / cli.c < prev    next >
C/C++ Source or Header  |  1991-04-18  |  2KB  |  90 lines

  1. /*
  2.  *  a2, an Apple II emulator in C
  3.  *  (c) Copyright 1990 by Rich Skrenta
  4.  *
  5.  *  Command line interface written by Tom Markson
  6.  *
  7.  *  Distribution agreement:
  8.  *
  9.  *    You may freely copy or redistribute this software, so long
  10.  *    as there is no profit made from its use, sale, trade or
  11.  *    reproduction.  You may not change this copyright notice,
  12.  *    and it must be included prominently in any copy made.
  13.  *
  14.  *  Send emulator related mail to:  skrenta@blekko.commodore.com
  15.  *                    skrenta@blekko.uucp
  16.  */
  17.  
  18.  
  19.  
  20. #include    <stdio.h>
  21. #include    <setjmp.h>
  22. #include    <signal.h>
  23. #include    "a2.h"
  24. #include    "cli.h"
  25.  
  26.  
  27. FILE *logging_fp = NULL;
  28. long    breakpoint = -1;
  29. long    trace_lo = -1;
  30. long    trace_hi;
  31. int    in_cli;
  32.  
  33. unsigned short lpoint;        /* point where dissassembly occurs */
  34. long phantom_location = -1;
  35. int map_to_upper = 1;
  36. jmp_buf jb;
  37.  
  38. cli_catch() {
  39.     signal(SIGINT,cli_catch);
  40.     printf("\n");
  41.     longjmp(jb,1);
  42. }
  43.  
  44. cli() 
  45. {
  46.     char    foo[200];
  47.  
  48.     restore_term();
  49.     MoveCursor(term_lines, 0);
  50.     status(stdout);
  51.     in_cli = TRUE;
  52.     lpoint = Pc;
  53.     signal(SIGINT, cli_catch);
  54.     setjmp(jb);
  55.     do {
  56.         printf(">>>");
  57.         if (fgets(foo, 200, stdin) == NULL) {
  58.             printf("\n");
  59.             exit(0);
  60.         }
  61.         foo[strlen(foo)-1] = '\0';
  62.         if (parse(first_tbl, foo)) {
  63.             running = FALSE;
  64.             tracing = FALSE;
  65.             return;            /* single step; no redraw */
  66.         }
  67.     } while (in_cli);
  68.  
  69.     set_term();
  70.     redraw_screen();
  71.     if (breakpoint != -1 || trace_lo != -1) {
  72.         tracing = TRUE;
  73.         running = FALSE;
  74.     } else {
  75.         tracing = FALSE;
  76.         running = TRUE;
  77.     }
  78. }
  79.  
  80.  
  81. status(fp)
  82. FILE *fp;
  83. {
  84.  
  85.     diss(Pc, fp);
  86.     flags(fp);
  87. }
  88.  
  89.  
  90.